'''
Created on Apr 21, 2013

@author: kevinbauer
'''

import numpy as np

class NormalData(object):

    def __init__(self):
        pass
    
    def normalize(self,inputData):

    #  normalize function is: y = ( x - min )/( max - min )

        temp = [] # initial array of the data, but it will reshaped in a multi-dimensional numpy array.
        maximum = inputData[0:,0:-1].max(axis=0)
        minimum = inputData[0:,0:-1].min(axis=0)
        
        denominator = maximum - minimum
        #denominator[[denominator == 0]] = 1
        zeroArr = np.zeros_like(denominator)
        denominator[denominator==zeroArr] = 1
        #print denominator
        
        for inputRow in inputData:
            exValueRow = inputRow[0:-1]
            valueRow = (exValueRow  - minimum)
            divValue = np.divide(valueRow, denominator)
  
            inputRow[0:-1] = divValue
            
            temp.append(inputRow)
        
        return temp